package com.zx.springboot.controller;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.zx.springboot.config.RabbitmqConfig;
import com.zx.springboot.pojo.User;

/***
 * 消费者1，消费指定队列
 * @author Administrator
 */
@Component
public class MessegeConsumer {
	// queues是指要监听的队列的名字
    @RabbitListener(queues = RabbitmqConfig.QUEUE)
    public void receiverDirectQueue(Message msg) {
    	User user = new User();
    	if(null!=msg) {
    		String info = new String(msg.getBody());
    		user = JSON.parseObject(info, User.class);
    	}
        System.out.println("consumer-9001-"+user);
    }
}
